package com.puboot.module.service.impl;

import com.puboot.module.model.RCateComic;
import com.puboot.module.mapper.RCateComicMapper;
import com.puboot.module.service.RCateComicService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;


/**
 * (RCateComic)表服务实现类
 *
 * @author Leonidax
 * @since 2024-10-11 17:00:04
 */
@Service
@AllArgsConstructor
public class RCateComicServiceImpl extends ServiceImpl<RCateComicMapper,RCateComic> implements RCateComicService {
    
    private final RCateComicMapper rCateComicMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param cateId 主键
     * @return 实例对象
     */
    @Override
    public RCateComic queryById(Integer cateId) {
        return rCateComicMapper.queryById(cateId);
    }

    /**
     * 分页查询
     *
     * @param rCateComic 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<RCateComic> queryByPage(RCateComic rCateComic, PageRequest pageRequest) {
        long total = rCateComicMapper.count(rCateComic);
        return new PageImpl<>(rCateComicMapper.queryAllByLimit(rCateComic, pageRequest), pageRequest, total);
    }

    /**
     * 修改数据
     *
     * @param rCateComic 实例对象
     * @return 实例对象
     */
    @Override
    public RCateComic update(RCateComic rCateComic) {
        this.rCateComicMapper.update(rCateComic);
        return this.queryById(rCateComic.getCateId());
    }

    /**
     * 通过主键删除数据
     *
     * @param cateId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer cateId) {
        return this.rCateComicMapper.deleteById(cateId) > 0;
    }
}
